From 16df1ab41ec9fe2b0605cbf358d5a0e5a82f0a43 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Jul 2014 12:08:13 -0700 Subject: [PATCH] Tighten up some tests --- tests/test_cargo_compile_path_deps.rs | 22 +++++++++------------- tests/test_cargo_test.rs | 27 +++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 3c6fa7c0d..3b031301c 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -97,32 +97,28 @@ test!(cargo_compile_with_root_dev_deps { [dev-dependencies.bar] version = "0.5.0" - path = "bar" + path = "../bar" [[bin]] - name = "foo" "#) - .file("src/foo.rs", - main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice()) - .file("bar/Cargo.toml", r#" - [project] + .file("src/main.rs", + main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice()); + let p2 = project("bar") + .file("Cargo.toml", r#" + [package] name = "bar" version = "0.5.0" authors = ["wycats@example.com"] - - [[lib]] - - name = "bar" "#) - .file("bar/src/bar.rs", r#" + .file("src/lib.rs", r#" pub fn gimme() -> &'static str { "zoidberg" } - "#) - ; + "#); + p2.build(); assert_that(p.cargo_process("cargo-build"), execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\ {} foo v0.5.0 (file:{})\n", diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 77f90feb5..ed3f488a4 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -47,13 +47,36 @@ test!(test_with_lib_dep { version = "0.0.1" authors = [] "#) - .file("src/lib.rs", "pub fn foo(){}") + .file("src/lib.rs", " + pub fn foo(){} + #[test] fn lib_test() {} + ") .file("src/main.rs", " extern crate foo; + fn main() {} + + #[test] + fn bin_test() {} "); - assert_that(p.cargo_process("cargo-test"), execs().with_status(0)); + assert_that(p.cargo_process("cargo-test"), + execs().with_status(0) + .with_stdout(format!("\ +{compiling} foo v0.0.1 (file:{dir}) + +running 1 test +test bin_test ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + + +running 1 test +test lib_test ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +", compiling = COMPILING, dir = p.root().display()).as_slice())); }) test!(test_with_deep_lib_dep { -- 2.30.2